<template>
  <div class="nav-box" v-show="hidden">
    <div class="nav-ce">
      <div class="logo-box">
        <!-- 	<img src="../assets/img/REDPANDADAOh.png" /> -->
      </div>
      <div class="nav">
        <router-link to="/">HOME</router-link>
        <router-link to="history">HISTORY</router-link>
        <router-link to="pro">PROJECT</router-link>
        <router-link to="activity">INFORMATION</router-link>
      </div>

      <div class="right-box">
        <div class="miusc-box">
          <Aplayer
            :music="audioList[0]"
            :list="audioList"
            :showlrc="false"
            :mini="false"
            :listFolded="true"
            :autoplay="true"
          ></Aplayer>
        </div>
        <div class="changeCH">
          <!-- <img src="../assets/img/eth.png" > -->
        </div>
        <div class="button" v-if="account">
          {{ getAccount }}
        </div>
        <div class="button" v-else @click="handleLogin">
          CONNECT WALLET
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Aplayer from "vue-aplayer";
import { mapState } from "vuex";

export default {
  components: {
    Aplayer
  },
  computed: {
    ...mapState(["account"]),
    getAccount() {
      if (this.account) {
        return (
          this.account.substring(0, 8) +
          "..." +
          this.account.substring(this.account.length - 6, this.account.length)
        );
      } else {
        return "";
      }
    }
  },
  data() {
    return {
      hidden: true,
      audioList: [
        {
          title: "歌曲名字",
          artist: "万云翔", //作者没有可以是undefined
          url: "http://r5r63bt34.hn-bkt.clouddn.com/test.mp3", //歌曲连接
          pic: "", //图片可以是空值
          lrc: "" //歌词可以是空值
        },
        {
          title: "歌曲名字",
          artist: "万云翔",
          url: "http://r5r63bt34.hn-bkt.clouddn.com/test.mp3",
          pic: "",
          lrc: ""
        },
        {
          title: "歌曲名字",
          artist: "万云翔",
          url: "http://r5r63bt34.hn-bkt.clouddn.com/test.mp3",
          pic: "",
          lrc: ""
        }
      ]
    };
  },
  mounted: function() {
    let that = this;
    window.addEventListener("scroll", this.hiddenNav);
    //请求歌曲列表数据
    that.$get("music?language=1", {}).then(res => {
      console.log(res.audioList);
      //that.audioList = res.audioList;
    });
  },
  methods: {
    handleLogin() {
      this.$store.dispatch("setWallet");
    },
    hiddenNav: function() {
      let scroll = document.documentElement.scrollTop;
      if (scroll > 120) {
        this.hidden = false;
      } else {
        this.hidden = true;
      }
    }
  }
};
</script>

<style scoped>
.nav-box {
  width: 100%;
  height: 80px;
  background-color: rgba(255, 255, 255, 1);
  position: fixed;
  top: 0px;
  z-index: 999;
}

.nav-ce {
  width: 100%;
  margin: auto;
  padding-left: 80px;
  padding-right: 80px;
  height: 80px;
  box-sizing: border-box;
}

/* @media screen and ( max-width: 1920px )  {
		.nav-ce{
			 width: 100%;
			 margin: auto;
			 height: 80px;

		}
	} */
.logo-box {
  float: left;
  display: flex;
  width: 260px;
  height: 80px;
  background-image: url(../assets/img/REDPANDADAOh.png);
  background-position: center;
  background-size: 100% auto;
  background-repeat: no-repeat;
  margin-right: 30px;
}

.nav {
  float: left;
  line-height: 80px;
  width: 30%;
  display: flex;
}

.nav a {
  color: #666;
  font-size: 18px;
  font-weight: bold;
  flex: 1;
  text-align: center;
}

.nav a:hover {
  color: #444;
}

.miusc-box {
  float: left;
  height: 80px;
  padding-top: 3px;
  box-sizing: border-box;
}

.title {
  width: 100%;
  height: 40px;
  line-height: 40px;
  text-align: right;
  color: #99989d;
  font-size: 14px;
  font-weight: bold;
}

.changeCH {
  float: left;
  width: 200px;
  height: 80px;
  color: #666;
  cursor: pointer;
  margin-right: 20px;
  background-image: url(../assets/img/eth.png);
  background-position: center;
  background-size: 100% auto;
  background-repeat: no-repeat;
}
.changeCH img {
  width: 100%;
}
.logo-box img {
  width: 100%;
}
.button {
  float: left;
  width: 240px;
  height: 48px;
  color: #444;
  font-weight: bold;
  text-align: center;
  border: 2px solid #444;
  font-size: 18px;
  margin-top: 16px;
  line-height: 48px;
  cursor: pointer;
}

.right-box {
  float: right;
  height: 80px;
  position: relative;
}

.step-box {
  width: 300px;
  height: 4px;
  background-color: #99989d;
  border-radius: 10px;
}

.step-icon {
  position: absolute;
  height: 14px;
  width: 14px;
  border-radius: 50%;
  background-color: #99989d;
  left: 0px;
  top: 35px;
}
/deep/ .aplayer-info {
  -webkit-box-flex: 1;
  -ms-flex-positive: 1;
  flex-grow: 1;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  text-align: start;
  padding: 14px 7px 0 10px !important;
  height: 66px !important;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  overflow: hidden;
}
/deep/ .aplayer-title {
  font-size: 14px !important;
}
/deep/ .aplayer-author {
  font-size: 12px !important;
  color: #666;
}
/deep/ .aplayer-pic {
  height: 66px !important;
  width: 66px !important;
}
/* /* /* 	自适应 */
/* @media screen and (max-width:1850px) {
		.nav-box{
			height: 110px;
		}
		.logo-box{
			width: 15%;
		}
		.logo-box img{
			width: 100%;
		}
		.nav-ce{
			padding-left: 30px;
			padding-right: 30px;
		}
		.nav a {
			font-size: 16px;
		}
		.button{
			width: 180px;
			font-size: 16px;
			height: 40px;
			color: #444;
			font-weight: bold;
			text-align: center;
			border: 1px solid #444;
			margin-top: 35px;
			line-height: 40px;
		}
	}
	@media screen and (max-width:1400px) {
		.nav a {
			font-size: 14px;
		}
		.button{
			width: 140px;
			font-size: 12px;
			height: 30px;
			color: #444;
			font-weight: bold;
			text-align: center;
			border: 1px solid #444;
			margin-top: 45px;
			line-height: 30px;
		}
	} */
</style>
